import 'package:flutter/material.dart';

class MessagePage extends StatefulWidget {
  @override
  _MessagePageState createState() => _MessagePageState();
}

class _MessagePageState extends State<MessagePage> {

  ScrollController controller1 = ScrollController();
  ScrollController controller2 = ScrollController();
  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    controller2.addListener(() {
      print(controller2.offset.toString());
      controller1.jumpTo(controller2.offset);

    });
  }
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text("站内信"),),
      body: NestedScrollView(
        headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {
          return <Widget>[SliverAppBar(
            leading: SizedBox(),
            title: Container(height: 100,width: double.infinity,color: Colors.green,),
          )];
        },
        body: ListView.builder(itemBuilder: (BuildContext context,int index){
          return Container(
            height: 80,
            color: Colors.primaries[index % Colors.primaries.length],
            alignment: Alignment.center,
            child: Text(
              '$index',
              style: TextStyle(color: Colors.white, fontSize: 20),
            ),
          );
        },itemCount: 20,),
      ),
    );
  }
}
